package com.hoshiicloud.mallshop.controller;

import com.hoshiicloud.auth.vo.TokenUsersVO;
import com.hoshiicloud.common.rpc.Response;
import com.hoshiicloud.common.utils.token.UserInfoUtil;
import com.hoshiicloud.mallshop.service.ShopConsumersService;
import com.hoshiicloud.user.param.PlatStoreConsumerPageParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.catalina.servlet4preview.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

/**
 * @program: hoshiicloud-biz
 * @description: 平台消费者控制器
 * @author: Mr.wu
 * @create: 2019-08-13 09:47
 **/
@RestController
@Api(tags = "平台消费者")
@Slf4j
@RequestMapping("/consumers")
public class ShopConsumersController {

    @Autowired
    private ShopConsumersService consumersService;

    @PostMapping(value = "/getStoreConsumersPage")
    @ApiOperation(value = "分页查询店铺消费者列表")
    public Response getStoreConsumersPage(@RequestBody PlatStoreConsumerPageParam param,@ApiIgnore HttpServletRequest request){
        //获取登录用户的店铺
        //获取上级id
        try{
            TokenUsersVO user = UserInfoUtil.getUserInfo(request);
            return consumersService.getStoreConsumersPage(param,user);
        }catch (Exception e){
            e.printStackTrace();
            log.error("店铺查询消费者列表异常",e);
            return Response.failed("查询异常"+e.toString());
        }

    }
}
